using System.Collections.Generic;

namespace Monopoly
{
    public class Player
    {
        private Board _board;
        private List<Die> _dice;
        private string _name;
        public const int TOTAL_DICE=2;

        public Player(string name, Board board, List<Die> dice)
        {
            _board = board;
            Location = _board.GoSquare;
            _dice = dice;
            _name = name;
        }

        public Square Location { get; private set; }

        public int TotalValue { get; private set; }

        public string Name
        {
            get { return _name; }
        }

        public void TakeTurn()
        {
            _dice.ForEach(die => die.Roll());
            TotalValue = 0;
            _dice.ForEach(die => TotalValue += die.FaceValue);
            Location = _board.GetSquareWithOffset(Location, TotalValue);
        }

        public bool IsAt(Square location)
        {
            return Location == location;
        }
    }
}